from meiduo_mall.libs.meiduo_express import MeiduoExpress
from meiduo_mall.apps.MeiduoExpress.models import ExpressInfo
from celery_tasks.main import celery_app

@celery_app.task(name='verify_express')
def verify_express(data, staff):
    me = MeiduoExpress()
    result = me.place_order(data)
    if result.get('Success'):
        ExpressInfo.objects.create(
            order_id=result['Order']['OrderCode'],
            staff = staff,
            logistic_code=result['Order']['LogisticCode'],
            shipper_code=result['Order']['ShipperCode']
        )
        return True
    return False